package com.tlcx.kfip.activity.main.mine;

import android.content.Context;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import com.tlcx.kfip.R;
import com.tlcx.kfip.activity.base.AppBaseActivity;
import com.tlcx.kfip.fragment.base.BaseFragment;
import com.tlcx.kfip.fragment.main.BillFragment;
import com.tlcx.kfip.fragment.main.IPRecordsAleadyAnnouncedFragment;
import com.tlcx.kfip.fragment.main.IPRecordsOngoingFragment;
import com.tlcx.kfip.fragment.main.KFIPFragment;
import com.tlcx.kfip.fragment.main.LastAnnounceFragment;
import com.tlcx.kfip.fragment.main.MineFragment;
import com.tlcx.kfip.fragment.main.WulinPartyFragment;
import android.support.v4.app.FragmentPagerAdapter;
import com.tlcx.kfip.ui.HeaderView;
import com.tlcx.kfip.ui.RVPIndicator;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 夺宝记录页面
 * Created by victor on 2016/10/2 17:13.
 * Email:zhuzhaoyang@yuanchuangyun.com
 */
public class IPRecordsAct extends AppBaseActivity{

    @BindView(R.id.widget_header_view)
    HeaderView mHeaderView;
    @BindView(R.id.indicator)
    RVPIndicator mRVPIndicator;
    @BindView(R.id.viewpager)
    ViewPager mViewPager;

    private List<BaseFragment> fragments;     //碎片集合
    private List<String> mTitles;
    private FragmentPagerAdapter mAdapter;

    public static Intent newIntent(Context context){
        return new Intent(context,IPRecordsAct.class);
    }

    @Override
    protected void initVariables() {
        //填充碎片数据源
        fragments = new ArrayList<>();
        fragments.add(new IPRecordsOngoingFragment());
        fragments.add(new IPRecordsAleadyAnnouncedFragment());

        mTitles = Arrays.asList(getResources().getStringArray(R.array.ip_records_tabs));
        mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public int getCount() {
                return fragments.size();
            }

            @Override
            public Fragment getItem(int position) {
                return fragments.get(position);
            }
        };

    }

    @Override
    protected void initViews() {
        setContentView(R.layout.act_ip_records);
        ButterKnife.bind(this);
        setHeaderView();
        mRVPIndicator.setLinePadding(24);
        configViews();
    }

    @Override
    protected void loadData() {

    }

    /**
     * 设置头部
     */
    private void setHeaderView(){
        mHeaderView.setBackListener(new BackListener());
        mHeaderView.setTitle(R.string.title_ip_records);
    }
    /**
     * 设置导航栏 以及ViewPage联动
     */
    private void configViews(){
        mRVPIndicator.setTabItemTitles(mTitles);
        mViewPager.setAdapter(mAdapter);
        mViewPager.setOffscreenPageLimit(3);
        mRVPIndicator.setViewPager(mViewPager, 0);
    }
}
